<!DOCTYPE html>
<html class="Content">
<head>
    <title>xUnit.js: Failures, Errors, and Script Errors</title>
    <link type="text/css" rel="Stylesheet" href="../../Style/documentation.css" />
</head>
<body>
    <h1>Failures, Errors, and Script Errors</h1>
    <p>
        This example is based on <em>Examples/Tests/Error Conditions/ErrorTests.js</em>, <em>Examples/Tests/Error Conditions/FailureTests.js</em>, 
        and <em>Examples/Tests/Error Conditions/ScriptErrorTests.js</em> from <a href="examples.zip">examples.zip</a>.
    </p>
    <p>
        xUnit.js provides several levels of interruption:
    </p>
    <h3>Failures:</h3>
    <p>
        Failures are violations of test expectations. These are considered normal, and do not interrupt test runs. They are caused by a failed assertion, 
        or a thrown <strong>xUnit.js.Model.AssertError</strong>:
        <span class="Code">
Function.RegisterNamespace("Test.ErrorConditions");

[Fixture]
Test.ErrorConditions.FailureTests=function(){
	[Fact]
	function FailsOnEqualityAssertion(){
		var expected=true;

		var actual=false;

		Assert.Equal(expected, actual);
	}
}
        </span>
    </p>
    <h3>Errors:</h3>
    <p>
        Errors are syntax or language violations that occur <em>inside</em> a test. These are also considered normal and do not interrupt test runs:
        <span class="Code">
Function.RegisterNamespace("Test.ErrorConditions");

[Fixture]
Test.ErrorConditions.ErrorTests=function(){
	[Fact]
	function ErrorsOnUnknownMember(){
		var expected=true;

		var actual={value:true}.slice(0,1);

		Assert.Equal(expected, actual);
	}
}    
        </span>
    </p>
    <h3>Script Errors:</h3>
    <p>
        Script Errors represent syntax or language violations that occur <em>outside</em> of a test. These can prevent test registration, and halt the interpretation of files 
        and fixtures. Script Errors should be addressed before Failures or regular Errors, as they have the ability to conceal multiple issues:
        <span class="Code">
Function.RegisterNamespace("Test.ErrorConditions");

[Fixture]
Test.ErrorConditions.ScriptErrorTests=function(){
	[Fact]
	function ThrowsSyntaxErrorOnLoad(){
		var expected=if(true));

		var actual=false;

		Assert.Equal(expected, actual);
	}
}
        </span>
    </p>
    <h3>System Errors:</h3>
    <p>
        System Errors are script errors that occur during the execution of the script load or action steps of an xUnit.js console run. These are typically only produced by errors in 
        custom host enviornment or I/O strategies. System Errors are halting, and abort the run, but still attempt to complete the epilogue of the output strategy.
    </p>
    <h3>Critical Errors:</h3>
    <p>
        Critical Errors are game over, man. If a script error occurs while collecting runtime parameters in the environment strategy; during the load of a script dependency; or in the
        output prologue; the entire run is aborted, and no attempt at recovery is made.
    </p>
</body>
</html>